home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / Transition.as < prev    next >
Text File  |  2013-04-24  |  2KB  |  71 lines

  1. class Transition extends State
  2. {
  3.    static var sEXCEPTION = "Instructions";
  4.    static var sSTATE_IDLE = "Idle";
  5.    static var sSTATE_PLAY_LEFT = "PlayLeft";
  6.    static var sSTATE_PLAY_RIGHT = "PlayRight";
  7.    static var nFRAME_CHANGE = 30;
  8.    function Transition(_mcRef)
  9.    {
  10.       super(_mcRef,false);
  11.       this.setState(Transition.sSTATE_IDLE);
  12.       this.bIsLeft = !!Math.round(Math.random());
  13.    }
  14.    function goTo(_sGoingTo, _classToMove)
  15.    {
  16.       this.sGoingTo = _sGoingTo;
  17.       if(!(_classToMove instanceof State) || (_classToMove == undefined || _classToMove == null))
  18.       {
  19.          this.classToMove = Main.getRef();
  20.       }
  21.       else
  22.       {
  23.          this.classToMove = _classToMove;
  24.       }
  25.       if(this.sState == Transition.sSTATE_IDLE)
  26.       {
  27.          if(this.bIsLeft)
  28.          {
  29.             this.setState(Transition.sSTATE_PLAY_RIGHT);
  30.             this.bIsLeft = false;
  31.          }
  32.          else
  33.          {
  34.             this.setState(Transition.sSTATE_PLAY_LEFT);
  35.             this.bIsLeft = true;
  36.          }
  37.       }
  38.       Controller.getRef().getSounds().playSound("SFX_Transition",Controller.nSFX_VOLUME,1);
  39.    }
  40.    function managePlayAnim()
  41.    {
  42.       if(this.stateFinished())
  43.       {
  44.          this.setState(Transition.sSTATE_IDLE);
  45.       }
  46.       else if(this.mcRef.mcState._currentframe == Transition.nFRAME_CHANGE)
  47.       {
  48.          if(this.sGoingTo != Transition.sEXCEPTION)
  49.          {
  50.             Controller.getRef().getInstructions().doHide();
  51.             this.classToMove.setState(this.sGoingTo);
  52.          }
  53.          else
  54.          {
  55.             Controller.getRef().getInstructions().doShow();
  56.          }
  57.       }
  58.    }
  59.    function Idle()
  60.    {
  61.    }
  62.    function PlayLeft()
  63.    {
  64.       this.managePlayAnim();
  65.    }
  66.    function PlayRight()
  67.    {
  68.       this.managePlayAnim();
  69.    }
  70. }
  71.